package org.jingouzhui.domain.strategy.service.rule.tree.factory;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jingouzhui.domain.strategy.model.valboj.RuleLogicCheckTypeVO;
import org.jingouzhui.domain.strategy.model.valboj.RuleTreeVO;
import org.jingouzhui.domain.strategy.service.rule.tree.ILogicTreeNode;
import org.jingouzhui.domain.strategy.service.rule.tree.factory.engine.IDecisionTreeEngine;
import org.jingouzhui.domain.strategy.service.rule.tree.factory.engine.impl.DecisionTreeEngine;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @description: 规则树工厂
 * @author: jingouzhui
 * @date: 2025/5/1 16:47
 */
@Service
public class DefaultTreeFactory {

    private final Map<String, ILogicTreeNode> logicTreeNodeMap;



    public DefaultTreeFactory(Map<String, ILogicTreeNode> logicTreeNodeMap) {
        this.logicTreeNodeMap = logicTreeNodeMap;
    }

    public IDecisionTreeEngine openLogicTree(RuleTreeVO ruleTreeVO){
        return new DecisionTreeEngine(logicTreeNodeMap,ruleTreeVO);
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class StrategyAwardVO {
        /** 抽奖奖品ID - 内部流转使用 */
        private Integer awardId;
        /** 抽奖奖品规则 */
        private String awardRuleValue;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class TreeActionEntity{
        private StrategyAwardVO strategyAwardVO;
        private RuleLogicCheckTypeVO ruleLogicCheckTypeVO;
    }


}
